﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Earthwatchers Admin</title>
    <script src="jquery-1.6.2.min.js" type="text/javascript"></script>
    <script src="jquery.base64.js" type="text/javascript"></script>

    <script type="text/javascript">
        function getAuthString() {
            return "Basic " + $.base64Encode(document.getElementById("tbUsername").value + ":" + document.getElementById("tbPassword").value);
        }

        $(function () {

            $("#LoadLandsButton").click(function () {
                $.ajax({
                    type: "GET",
                    data: "{\"Name\":\"" + document.getElementById("tbUsername").value + "\",\"Password\":\"" + document.getElementById("tbPassword").value + "\" }",
                    url: "../api/land/landscsv",
                    beforeSend: function (xhr) {
                        xhr.setRequestHeader("Authorization", getAuthString());
                    },
                    contentType: "application/json ; charset=utf-8",
                    dataType: "json",
                    success: function (result) {
                        $(result).each(function () {
                            var html = $(this).attr('Id')
                            + ',' + $(this).attr('Latitude')
                            + ',' + $(this).attr('Longitude')
                            + ',' + $(this).attr('GeohexKey')
                            + ',' + $(this).attr('LandThreat')
                            + ',' + $(this).attr('LandStatus')
                            + ',' + $(this).attr('StatusChangedDateTime')
                            + ',' + $(this).attr('DemandAuthorities')
                            + ',' + $(this).attr('DemandUrl')
                            + ',' + $(this).attr('LastReset')
                            + ',' + $(this).attr('EarthwatcherId')
                            + ',' + $(this).attr('EarthwatcherName')
                            + ',' + $(this).attr('OKsDetail')
                            + ',' + $(this).attr('SuspiciousDetail')
                            + ',' + $(this).attr('OKs')
                            + ',' + $(this).attr('Suspicious') + '<br />';

                            $('<span></span>').html(html).appendTo('#landstable');
                        });
                    },
                    error: function (xhr, textStatus, errorThrown) {
                        alert(errorThrown);
                    }
                });
            });
        });
    </script>
    <style>
        body {
            font-family: Helvetica, Arial, "Lucida Grande", sans-serif;
        }

        .tdnumber {
            text-align: right;
        }

        .tdcheck {
            text-align: center;
        }

        .url {
            width: 300px;
        }
    </style>
</head>
<body>
    <h3>Administrator - Statistics</h3>
    <br />
    <br />
    username:
    <input type="text" id="tbUsername" value="" /><br />
    password:
    <input type="password" id="tbPassword" value="" />
    <br />
    <br />
    <input id="LoadLandsButton" type="button" value="Cargar CSV" />
    <br />
    <br />
    Id,Latitude,Longitude,GeohexKey,LandThreat,LandStatus,StatusChangedDateTime,DemandAuthorities,DemandUrl,LastReset,EarthwatcherId,EarthwatcherName,OKsDetail,SuspiciousDetail,OKs,Suspicious
    <div id="landstable"></div>
    <br />
    <br />
    <a href="index.html">back</a>

</body>
</html>
